package com.gistmap.sideline.web;

import com.gistmap.sideline.common.PageParam;
import com.gistmap.sideline.dto.SidelineDTO;
import com.gistmap.sideline.response.Result;
import com.gistmap.sideline.service.SidelineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "副业接口")
@RestController
@RequestMapping("/api/sideline")
public class SidelineController {

    @Autowired
    private SidelineService sidelineService;

    @GetMapping
    @ApiOperation(value = "根据条件返回副业列表")
    public Result findAll(@ModelAttribute PageParam pageParam){
        return new Result().success(sidelineService.findAll(pageParam));
    }

    @PostMapping
    @ApiOperation(value = "新增一条副业")
    public Result save(@RequestBody SidelineDTO dto){
        sidelineService.save(dto);
        return new Result().success();
    }
}
